Custom counters

Should be enabled the MSBuild & SBE-Scripts.

Increment & Decrement Numbers

Syntactic sugar of v0.12.8+

v0.12.8+ Contains syntactic sugar: += & -=

#[Box iterate(i = 0; $(i) < 10; i += 1): 
    ...
    $(numA += 3.14)
    $(numB -= 1)
]

other

Very old examples: Read Math page + please fix me

Information for this section is not complete or temporarily is not available. To fix it, click - Edit

Example of counter in the range 1 - 10:

#[( $(counter) == "*Undefined*" ) {
    #[var counter = 0]
}]

    $(counter = $([MSBuild]::Add($(counter), 1)))

    #["
        The variable $(counter) should contain the number in the range 1 - 10
    "]

#[( $(counter) >= 10 ) {
    #[var counter = 0]
}]

a more exotic control ? no problem:

#[($(numX) == "*Undefined*") {
    #[var numX    = 0]
    #[var numY    = 0]
    #[var numYmod = 0]
}]

$(numY    = $([MSBuild]::Add($(numY), 1)))
$(numYmod = $([MSBuild]::Modulo($(numY), 12)))

#[($(numYmod) == 0) {
    $(numX = $([MSBuild]::Add($(numX), 1)))
}]

#[var spec = $(numX).$(numYmod).$(numY)]

The variable spec in example above should contain the next values - Value of variable - spec

Other Math

Unique number for team

The most CI servers already should provide special environment variable, like a $(appveyor_build_version), $(BUILD_NUMBER), etc. You may use this variable, or:

  • Date & Time features, but it does not give any warranty for unique numbers in team, and you should use the our CI features or something else…
  • Sequential numbers
  • You can also use any cryptographic hash function (sha1, MD5, TTH etc.) with your specific unique identification (timestamp + computer identifier + … and similar), for example:
#[var utcnow = $([System.DateTime]::UtcNow.Ticks)]
#[File sout("cmd", "/C echo \"#[var utcnow]\" | openssl sha1 | sed 's/^.*\s//'")]

f80ba367786b1fc075bf04104a69656141202aa5

Note: In example above we use the openssl. However, v0.12.4+ now supports calculating MD5 & SHA1 for more convenience.

#[Func hash.SHA1("")]
#[Func hash.MD5("")]
$([System.Guid]::NewGuid())

364c741c-21da-4c85-8d33-abf15b7c9672

if need sha1 you can also recalculate this:

#[var guid = $([System.Guid]::NewGuid())]
#[File sout("cmd", "/C echo \"#[var guid]\" | openssl sha1 | sed 's/^.*\s//'")]

2580219018d287e84de683f4cd74822ba952c96f

and similar..

  • Use our Wizard as an easy step for quick results.

References

MSBuild Property Functions - you can use any static method or property of these system classes: